function $$(id) {
	return document.getElementById(id);
}

var uploader3 = new plupload.Uploader({
	multipart: true,
    multi_selection:true,
	// multi_selection : false,
	runtimes : 'gears,html5,html4,flash,silverlight,browserplus',
	browse_button : 'pickfiles3',
	container: 'container3',
	max_file_size : '100mb',
	// url : '/dev-api/upload/UploadFujian',
	url : '/prod-api/upload/UploadFujian',
	//resize : {width : 320, height : 240, quality : 90},
	flash_swf_url : '../js/plupload/plupload.flash.swf',
	silverlight_xap_url : '../js/plupload/plupload.silverlight.xap',
	filters : [
		{title : "Image files", extensions : "jpg,gif,png,bmp"}
	]
});

function InitUpLoader3()
{
	let file_url = []
	let width_arr = []
	let height_arr = []
	let rato_arr = []
	uploader3.bind('Init', function(up, params) {
		
		$$('filelist3').innerHTML = "";
	});

	uploader3.init();
	uploader3.bind('FilesAdded', function(up, files) {
		// file_url = files
		
		let result = '';
		for ( var i in files) {
			result += '<span id="' + files[i].id + '">' + files[i].name + ' (' + plupload.formatSize(files[i].size) + ') <b></b></span>'			
		}		
		$$('filelist3').innerHTML = result
		uploader3.start();
	});
	uploader3.bind('UploadProgress', function(up, file) {
		$$(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
	});
	
	uploader3.bind('FileUploaded', function(up, file, response) {	
		var ratio
		file_url.push(response.response)
		var mmResponse = (response.response).replace(/\\/g, "").replace(/(")/g, "");
	    var mmFileUrl = mmResponse;
		var img = new Image();
		img.onload = function() {	
			ratio = this.width/this.height
			rato_arr.push(ratio )
			$("#rato").val(rato_arr);
		};
		img.src = mmFileUrl;
	    $("#imageurl").val(file_url);
		
	});
	uploader3.bind("UploadComplete", function(up,files) {
		// console.log(files)
    });

	uploader3.bind('Error', function(up, err) {
	    //alert("Error #" + err.code + ": " + err.message);
	});

//	$("#uploadfiles").bind("onclick",function() {
//		uploader2.start();
//		return false;
//	});
}


